import time
from day_827.Base import Base
from selenium.webdriver.common.by import By

class Page(Base):
    # 进入frame框架
    kj_loc = (By.XPATH,'//iframe[starts-with(@id,"x-URS-iframe")]')
    def kj(self):
        self.frame(self.kj_loc)

    # 输入用户名密码
    username_loc = (By.NAME,'email')
    def username(self):
        self.send_keys(self.username_loc,'s3080172040')

    password_loc = (By.NAME,'password')
    def password(self):
        self.send_keys(self.password_loc,'Xff030303')

    # 点击登录按钮
    loginbtn_loc = (By.XPATH,'//*[@id="dologin"]')
    def loginbtn(self):
        self.click(self.loginbtn_loc)

    # 写信
    wirte_loc = (By.XPATH, '//*[@id="_mail_component_98_98"]')
    def write(self):
        self.click(self.wirte_loc)

    # 收件人
    person_loc = (By.CLASS_NAME, 'nui-editableAddr-ipt')
    def person(self):
        self.send_keys(self.person_loc, '3080172040@qq.com')

    # 主题
    title_loc = (By.XPATH, '/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[2]/div[1]/div/div/input')
    def title(self):
        self.send_keys(self.title_loc, '主题')

    # 正文
    message_loc = (By.XPATH, '/html/body')
    def message(self):
        self.send_keys(self.message_loc, '你好')

    # 发送
    send_loc = (By.CLASS_NAME, 'nui-btn-text')
    def send(self):
        self.click(self.send_loc)


    def mail_01(self):
        self.open('https://mail.126.com/')
        self.kj()
        time.sleep(1)
        self.username()
        time.sleep(1)
        self.password()
        time.sleep(1)
        self.loginbtn()
        self.frame_q()
        time.sleep(3)
        self.write()
        time.sleep(1)
        self.person()
        time.sleep(1)
        self.title()
        time.sleep(1)
        self.message()
        time.sleep(1)
        self.send()
        time.sleep(1)